1. Field of the Invention
This invention relates to a method and an apparatus for encoding a moving-picture signal through signal processing steps including a step of calculating the complexity of a picture and a step of deciding a quantization scale used by the quantization of a signal segment representative of that picture in response to the calculated complexity.
2. Description of the Related Art
MPEG-2 (Moving Picture Experts Group Phase 2) means international standards for a technique of efficiently encoding a moving-picture signal such as a television signal. The MPEG-2 standards prescribe motion-compensated prediction and transform-based encoding which allow data compression.
The motion-compensated prediction is designed to implement the following steps. Each of frames constituting a moving-picture sequence is partitioned into equal-size blocks of pixels, that is, macroblocks of 16 by 16 pixels. A motion vector between a current picture and a reference picture is calculated for every macroblock. A predicted picture for the current picture is generated from the reference picture in response to the calculated motion vectors.
According to the transform-based encoding, a signal representative of the error (residual) between the current picture and the predicted picture is subjected to orthogonal transform, specifically discrete cosine transform (DCT). When the current picture is selected as an intra-coded picture (I-picture), the current picture is directly subjected to DCT.
Japanese patent application publication number 6-141298/1994 discloses a variable-transfer-rate encoding apparatus for moving-picture data. In the apparatus of Japanese application 6-141298/1994, an input moving-picture signal is subjected to first encoding which uses a fixed quantization scale. The first encoding is referred to as tentative encoding. During the tentative encoding, the amount of encoded data (encoding-resultant data) is counted for every unit time interval. Target transfer rates are set on the basis of the counted data amounts for the respective unit time intervals. The target transfer rates are chosen so that the total amount of encoded data originating from the whole of the input moving-picture signal will be equal to a prescribed value. Finally, the input moving-picture signal is subjected to second encoding, that is, real encoding in which the actual amount of encoded data is controlled to equalize the actual transfer rate to the target transfer rate for every unit time interval.
The apparatus of Japanese application 6-141298/1994 is of a 2-path type, performing the encoding of the input moving-picture signal twice. Therefore, the apparatus is unsuited to usage requiring real-time signal processing.
Japanese patent application publication number 10-164577/1998 discloses a moving-picture data encoding apparatus of a 1-path type which encodes moving-picture data at a variable rate on a real-time basis. In the apparatus of Japanese application 10-164577/1998, the amount of encoded data (encoding-resultant data) is counted for every frame, and the average value of quantization step sizes for the respective macroblocks constituting that frame is calculated. The counted amount of encoded data and the calculated average quantization step size are multiplied to get a complexity of that frame. The average value of the complexities of past frames is calculated. The ratio between the calculated average past-frame complexity and the complexity of a current frame is computed. A desired amount of encoded data for a next frame is decided on the basis of the computed complexity ratio. A quantization step size for the next frame is determined in response to the desired amount of encoded data for the next frame. A moving-picture data segment representing the next frame is quantized in accordance with the determined quantization step size.
In the apparatus of Japanese application 10-164577/1998, the ratio between the average past-frame complexity and the current-frame complexity is used to decide the desired amount of encoded data for the next frame. Thus, the desired amount of encoded data for the next frame is decided on the basis of the current-frame complexity. Generally, in the case where a scene change occurs between the current frame and the next frame, a greater desired amount of encoded data for the next frame is nice to attain a good picture quality. In the apparatus of Japanese application 10-164577/1998, the desired amount of encoded data for the next frame tends to be less than the desirable greater value since it is decided on the basis of the current-frame complexity. Thus, a picture quality tends to drop immediately after the scene change.
In the apparatus of Japanese application 10-164577/1998, there are an average past-frame complexity corresponding to past I pictures (intra-coded pictures), an average past-frame complexity corresponding to past P pictures (forward predictive coded pictures), and an average past-frame complexity corresponding to past B pictures (bidirectionally predictive coded pictures). When the next frame is an I picture, the ratio between the past past-I-frame complexity and the complexity of the last I frame is used to decide the desired amount of encoded data for the next frame. When the next frame is a P picture, the ratio between the average past-P-frame complexity and the complexity of the last P frame is used to decide the desired amount of encoded data for the next frame. When the next frame is a B picture, the ratio between the average past-B-frame complexity and the complexity of the last B frame is used to decide the desired amount of encoded data for the next frame. Generally, in the case where a scene change occurs between the next frame and the last frame of the picture type same as that about the next frame, a greater desired amount of encoded data for the next frame is nice to attain a good picture quality. In the apparatus of Japanese application 10-164577/1998, the desired amount of encoded data for the next frame tends to be less than the desirable greater value since it is decided on the basis of the complexity of the last frame of the picture type same as that about the next frame. Thus, a picture quality tends to drop immediately after the scene change. Especially, a picture quality tends to significantly drop when the last frame and the next frame are B pictures.
Japanese patent application publication number 2001-238215 discloses a moving picture encoding apparatus in which input moving pictures are of I, P, and B types, and thus the input moving pictures include I pictures, P pictures, and B pictures. A signal related to the input moving pictures is quantized in response to a variable quantization scale factor before being encoded. The apparatus in Japanese application 2001-238215 has a device for detecting a scene change in the input moving pictures and identifying a scene change picture thereamong. In the apparatus of Japanese application 2001-238215, an actual complexity of each past encoded picture originating from one of the input moving pictures is calculated. A complexity of a next encoded picture being either a P picture or a B picture is estimated in response to the actual complexity of a past encoded picture same in type as the next encoded picture regardless of whether or not the next encoded picture is a scene change picture. A value of the quantization scale factor used for the quantization is decided in response to the estimated complexity.